package o;

import java.io.IOException;
import java.nio.ByteBuffer;

final class fxq implements fxj {
    boolean ˊ;
    public final fxi ˏ = new fxi();
    public final fxx ॱ;

    fxq(fxx o_fxx) {
        if (o_fxx == null) {
            throw new NullPointerException("sink == null");
        }
        this.ॱ = o_fxx;
    }

    public fxi ˏ() {
        return this.ˏ;
    }

    public void ˎ(fxi o_fxi, long j) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ˎ(o_fxi, j);
        ˈ();
    }

    public fxj ˊ(fxh o_fxh) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ˎ(o_fxh);
        return ˈ();
    }

    public fxj ˋ(String str) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ˎ(str);
        return ˈ();
    }

    public fxj ˊ(byte[] bArr) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ˎ(bArr);
        return ˈ();
    }

    public fxj ˋ(byte[] bArr, int i, int i2) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ˊ(bArr, i, i2);
        return ˈ();
    }

    public int write(ByteBuffer byteBuffer) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        int write = this.ˏ.write(byteBuffer);
        ˈ();
        return write;
    }

    public long ˋ(fxw o_fxw) throws IOException {
        if (o_fxw == null) {
            throw new IllegalArgumentException("source == null");
        }
        long j = 0;
        while (true) {
            long ˊ = o_fxw.ˊ(this.ˏ, 8192);
            if (ˊ == -1) {
                return j;
            }
            j += ˊ;
            ˈ();
        }
    }

    public fxj ॱॱ(int i) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ˊ(i);
        return ˈ();
    }

    public fxj ʻ(int i) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ॱ(i);
        return ˈ();
    }

    public fxj ʼ(int i) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ˋ(i);
        return ˈ();
    }

    public fxj ˋॱ(long j) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ʽ(j);
        return ˈ();
    }

    public fxj ॱˊ(long j) throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        this.ˏ.ʻ(j);
        return ˈ();
    }

    public fxj ˈ() throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        long ॱॱ = this.ˏ.ॱॱ();
        if (ॱॱ > 0) {
            this.ॱ.ˎ(this.ˏ, ॱॱ);
        }
        return this;
    }

    public fxj ʼ() throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        long ॱ = this.ˏ.ॱ();
        if (ॱ > 0) {
            this.ॱ.ˎ(this.ˏ, ॱ);
        }
        return this;
    }

    public void flush() throws IOException {
        if (this.ˊ) {
            throw new IllegalStateException("closed");
        }
        if (this.ˏ.ˎ > 0) {
            this.ॱ.ˎ(this.ˏ, this.ˏ.ˎ);
        }
        this.ॱ.flush();
    }

    public boolean isOpen() {
        return !this.ˊ;
    }

    public void close() throws IOException {
        if (!this.ˊ) {
            Throwable th = null;
            try {
                if (this.ˏ.ˎ > 0) {
                    this.ॱ.ˎ(this.ˏ, this.ˏ.ˎ);
                }
            } catch (Throwable th2) {
                th = th2;
            }
            try {
                this.ॱ.close();
            } catch (Throwable th3) {
                if (th == null) {
                    th = th3;
                }
            }
            this.ˊ = true;
            if (th != null) {
                fxy.ॱ(th);
            }
        }
    }

    public fxv ˊ() {
        return this.ॱ.ˊ();
    }

    public String toString() {
        return "buffer(" + this.ॱ + ")";
    }
}
